﻿<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:SmoothStreaming="clr-namespace:Microsoft.Web.Media.SmoothStreaming;assembly=Microsoft.Web.Media.SmoothStreaming" xmlns:rad="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls" xmlns:telerik="clr-namespace:Telerik.Windows.Controls.Primitives;assembly=Telerik.Windows.Controls" xmlns:local="clr-namespace:jSLApp.Client.Controls" xmlns:Converters="clr-namespace:jSLApp.Client.Converters" xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions" xmlns:telerik1="http://schemas.telerik.com/2008/xaml/presentation" xmlns:System="clr-namespace:System;assembly=mscorlib" x:Class="jSLApp.Client.Controls.VRPlayer"
    d:DesignHeight="300" d:DesignWidth="400" mc:Ignorable="d" MouseWheel="mouse_Wheel" MouseMove="mouse_Moved"  KeyDown="key_Down" IsTabStop="True">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="../Resources/RadMediaPlayerStyle.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>    	
    </UserControl.Resources>    
    <Grid x:Name="root">
        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup x:Name="SoundVolume">
                <VisualStateGroup.Transitions>
                    <VisualTransition GeneratedDuration="0:0:0.1"/>
                </VisualStateGroup.Transitions>
                <VisualState x:Name="Muted">
                    <Storyboard>
                		<DoubleAnimation Duration="0" To="0.725" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="path" d:IsOptimized="True"/>
                		<DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="path2" d:IsOptimized="True"/>
                		<DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="path1" d:IsOptimized="True"/>
                		<DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="viewbox" d:IsOptimized="True"/>
                	</Storyboard>
                </VisualState>
                <VisualState x:Name="HalfVolume">
                    <Storyboard>
                		<DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="path1" d:IsOptimized="True"/>
                		<DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="path2" d:IsOptimized="True"/>
                	</Storyboard>
                </VisualState>
                <VisualState x:Name="FullVolume"/>
            </VisualStateGroup>
            <VisualStateGroup x:Name="ControlPanel1">
            	<VisualStateGroup.Transitions>
            		<VisualTransition GeneratedDuration="0" To="ControlPanelVisible"/>
            		<VisualTransition GeneratedDuration="0:0:2" To="ControlPanelHidden">
            			<VisualTransition.GeneratedEasingFunction>
            				<ExponentialEase EasingMode="EaseIn" Exponent="20"/>
            			</VisualTransition.GeneratedEasingFunction>
            		</VisualTransition>
            	</VisualStateGroup.Transitions>
            	<VisualState x:Name="ControlPanelHidden">
            		<Storyboard>
            			<DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="ControlPanel" d:IsOptimized="True"/>
            			<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.IsHitTestVisible)" Storyboard.TargetName="ControlPanel">
            				<DiscreteObjectKeyFrame KeyTime="0">
            					<DiscreteObjectKeyFrame.Value>
            						<System:Boolean>False</System:Boolean>
            					</DiscreteObjectKeyFrame.Value>
            				</DiscreteObjectKeyFrame>
            			</ObjectAnimationUsingKeyFrames>
            		</Storyboard>
            	</VisualState>
            	<VisualState x:Name="ControlPanelVisible"/>
            </VisualStateGroup>
            <VisualStateGroup x:Name="PlayOrPause">
            	<VisualState x:Name="Playing">
            		<Storyboard>
            			<DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="button" d:IsOptimized="True"/>
            			<DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="button1" d:IsOptimized="True"/>
            		</Storyboard>
            	</VisualState>
            	<VisualState x:Name="Paused"/>
            </VisualStateGroup>
            <VisualStateGroup x:Name="CommonState">
            	<VisualStateGroup.Transitions>
            		<VisualTransition GeneratedDuration="0:0:0.5" To="Ready"/>
            	</VisualStateGroup.Transitions>
            	<VisualState x:Name="Ready"/>
            	<VisualState x:Name="InProgress">
            		<Storyboard>
            			<DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="HeaderPresenter" d:IsOptimized="True"/>
            			<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(Control.IsEnabled)" Storyboard.TargetName="ControlPanel">
            				<DiscreteObjectKeyFrame KeyTime="0">
            					<DiscreteObjectKeyFrame.Value>
            						<System:Boolean>True</System:Boolean>
            					</DiscreteObjectKeyFrame.Value>
            				</DiscreteObjectKeyFrame>
            			</ObjectAnimationUsingKeyFrames>
            			<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.IsHitTestVisible)" Storyboard.TargetName="HeaderPresenter">
            				<DiscreteObjectKeyFrame KeyTime="0">
            					<DiscreteObjectKeyFrame.Value>
            						<System:Boolean>False</System:Boolean>
            					</DiscreteObjectKeyFrame.Value>
            				</DiscreteObjectKeyFrame>
            			</ObjectAnimationUsingKeyFrames>
            			<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="grid3">
            				<DiscreteObjectKeyFrame KeyTime="0">
            					<DiscreteObjectKeyFrame.Value>
            						<Visibility>Collapsed</Visibility>
            					</DiscreteObjectKeyFrame.Value>
            				</DiscreteObjectKeyFrame>
            			</ObjectAnimationUsingKeyFrames>
            		</Storyboard>
            	</VisualState>
            	<VisualState x:Name="Failed">
            		<Storyboard>
            			<DoubleAnimation Duration="0" To="1" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="failedPanel" d:IsOptimized="True"/>
            			<DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="grid3" d:IsOptimized="True"/>
            			<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.IsHitTestVisible)" Storyboard.TargetName="grid3">
            				<DiscreteObjectKeyFrame KeyTime="0">
            					<DiscreteObjectKeyFrame.Value>
            						<System:Boolean>False</System:Boolean>
            					</DiscreteObjectKeyFrame.Value>
            				</DiscreteObjectKeyFrame>
            			</ObjectAnimationUsingKeyFrames>
            		</Storyboard>
            	</VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>        
        <Rectangle Fill="Black" x:Name="vBrush"/>
        <Rectangle x:Name="vBrush3">
            <Rectangle.Fill>
                <VideoBrush x:Name="vBrush2" Stretch="Uniform"/>
            </Rectangle.Fill>
        </Rectangle>
        <ContentControl x:Name="HeaderPresenter" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Content="Это заголовок" Foreground="White" d:IsHidden="True" IsTabStop="False" IsHitTestVisible="False"/>
        
        <Grid x:Name="controlPanelSmallPresenter">
            <Grid.RowDefinitions>
            	<RowDefinition Height="8*"/>
            	<RowDefinition Height="*" MinHeight="50"/>
            </Grid.RowDefinitions>
            <UserControl x:Name="ControlPanel" Grid.Row="1" IsEnabled="False">                
                        <Grid x:Name="grid2" Background="#B2000000">                
                <Grid.RowDefinitions>
                	<RowDefinition/>
                	<RowDefinition/>
                </Grid.RowDefinitions>
                <Grid Grid.Row="0">
                    <Grid.Resources>
                        <ResourceDictionary>
                        	<Style TargetType="Button">
                        		<Setter Property="Background" Value="Transparent"/>
                        		<Setter Property="Margin" Value="0,3,0,0"/>
                        		<Setter Property="Template">                                    
                        			<Setter.Value>
                        				<ControlTemplate TargetType="Button">
                        					<ContentPresenter x:Name="contentPresenter" RenderTransformOrigin="0.5,0.5">
                        						<ContentPresenter.RenderTransform>
                        							<CompositeTransform/>
                        						</ContentPresenter.RenderTransform>
                        						<VisualStateManager.VisualStateGroups>
                        							<VisualStateGroup x:Name="CommonStates">
                        								<VisualStateGroup.Transitions>
                        									<VisualTransition GeneratedDuration="0:0:0.1"/>
                        								</VisualStateGroup.Transitions>
                        								<VisualState x:Name="Normal"/>
                        								<VisualState x:Name="MouseOver">
                        									<Storyboard>
                        										<DoubleAnimation Duration="0" To="1.1" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleX)" Storyboard.TargetName="contentPresenter" d:IsOptimized="True">
                        											<DoubleAnimation.EasingFunction>
                        												<ExponentialEase EasingMode="EaseInOut"/>
                        											</DoubleAnimation.EasingFunction>
                        										</DoubleAnimation>
                        										<DoubleAnimation Duration="0" To="1.1" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleY)" Storyboard.TargetName="contentPresenter" d:IsOptimized="True">
                        											<DoubleAnimation.EasingFunction>
                        												<ExponentialEase EasingMode="EaseInOut"/>
                        											</DoubleAnimation.EasingFunction>
                        										</DoubleAnimation>
                        									</Storyboard>
                        								</VisualState>
                        								<VisualState x:Name="Pressed">
                        									<Storyboard>
                        										<DoubleAnimation Duration="0" To="0.9" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleX)" Storyboard.TargetName="contentPresenter" d:IsOptimized="True">
                        											<DoubleAnimation.EasingFunction>
                        												<CubicEase EasingMode="EaseInOut"/>
                        											</DoubleAnimation.EasingFunction>
                        										</DoubleAnimation>
                        										<DoubleAnimation Duration="0" To="0.9" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleY)" Storyboard.TargetName="contentPresenter" d:IsOptimized="True">
                        											<DoubleAnimation.EasingFunction>
                        												<CubicEase EasingMode="EaseInOut"/>
                        											</DoubleAnimation.EasingFunction>
                        										</DoubleAnimation>
                        									</Storyboard>
                        								</VisualState>
                        								<VisualState x:Name="Disabled">
                        									<Storyboard>
                        										<DoubleAnimation Duration="0" To="0.745" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="contentPresenter" d:IsOptimized="True"/>
                        									</Storyboard>
                        								</VisualState>
                        							</VisualStateGroup>
                        						</VisualStateManager.VisualStateGroups>
                        					</ContentPresenter>
                        				</ControlTemplate>
                        			</Setter.Value>
                        		</Setter>
                        		<Setter Property="Cursor" Value="Hand"/>
                        	</Style>
                        	<Style TargetType="Border">
                        		<Setter Property="Background" Value="Transparent"/>
                        	</Style>
                        </ResourceDictionary>
                    </Grid.Resources>
                    <Grid.ColumnDefinitions>
                    	<ColumnDefinition Width="*"/>
                    	<ColumnDefinition Width="Auto"/>
                    	<ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>
                        <TextBlock x:Name="bpsTxt" Foreground="Gray" HorizontalAlignment="Right" VerticalAlignment="Center" Grid.ColumnSpan="3" Margin="0,0,20,0"/>
                        <Viewbox Grid.Column="0" Stretch="Uniform" HorizontalAlignment="Right" Margin="15,4,15,-4">
                        <Grid>                            
                        <Button x:Name="button1" Click="playPause_Clicked" Width="50" Height="50" BorderThickness="0" IsTabStop="False">
                            <Grid Background="Transparent">                                
                                <Ellipse Stroke="White" StrokeThickness="3" Fill="#01000001"/>
                                <Grid>
                                    <Grid.ColumnDefinitions>
                                    	<ColumnDefinition/>
                                    	<ColumnDefinition/>
                                    	<ColumnDefinition/>
                                    </Grid.ColumnDefinitions>
                                    <Grid.RowDefinitions>
                                    	<RowDefinition/>
                                    	<RowDefinition/>
                                    	<RowDefinition/>
                                    </Grid.RowDefinitions>
                                    <Path Grid.Row="1" Grid.Column="1" Stretch="Fill" StrokeThickness="1" StrokeLineJoin="Round" Stroke="#FF000000" Fill="#FFFFFFFF" Data="F1 M 88.0499,58.5L 42.9501,32.4616L 42.9501,84.5384L 88.0499,58.5 Z "/>
                                </Grid>
                            </Grid>
                        </Button>

                            <Button x:Name="button" Click="playPause_Clicked"  Width="50" Height="50" BorderThickness="0" Opacity="0" IsTabStop="False">
                                <Grid Background="Transparent">
                                    <Ellipse Stroke="White" StrokeThickness="3" Fill="#01000001"/>
                                    <Grid>
                                        <Grid.ColumnDefinitions>
                                        	<ColumnDefinition/>
                                        	<ColumnDefinition/>
                                        	<ColumnDefinition/>
                                        </Grid.ColumnDefinitions>
                                        <Grid.RowDefinitions>
                                        	<RowDefinition/>
                                        	<RowDefinition/>
                                        	<RowDefinition/>
                                        </Grid.RowDefinitions>
                                        <Grid Grid.Row="1" Grid.Column="1">
                                            <Grid.ColumnDefinitions>
                                            	<ColumnDefinition/>
                                            	<ColumnDefinition/>
                                            </Grid.ColumnDefinitions>
                                            <Path Margin="0,0,4,0" Stretch="Fill" StrokeThickness="1" StrokeLineJoin="Round" Stroke="#FF000000" Fill="#FFFFFFFF" Data="F1 M 0,0L 10,0L 10,100L 0,100 Z "/>
                                            <Path Margin="4,0,0,0" Stretch="Fill" StrokeThickness="1" StrokeLineJoin="Round" Stroke="#FF000000" Fill="#FFFFFFFF" Data="F1 M 0,0L 10,0L 10,100L 0,100 Z " Grid.Column="1"/>
                                        </Grid>
                                    </Grid>
                                </Grid>
                            </Button>
                            
                        </Grid>                        
                    </Viewbox>                                        
                        <Viewbox Grid.Column="1" Stretch="Uniform" Margin="15,4,15,-4">
                            <Button Click="toggleVolume_Clicked"  Width="50" Height="50" IsTabStop="False">
                                <Grid>
                                    <Ellipse Stroke="White" StrokeThickness="3" Fill="#01000001"/>
                                    <Grid x:Name="grid1">
                                        <Grid.ColumnDefinitions>
                                    	    <ColumnDefinition/>
                                    	    <ColumnDefinition/>
                                    	    <ColumnDefinition/>
                                        </Grid.ColumnDefinitions>
                                        <Grid.RowDefinitions>
                                    	    <RowDefinition/>
                                    	    <RowDefinition Height="2*"/>
                                    	    <RowDefinition/>
                                        </Grid.RowDefinitions>
                                            <Grid Grid.Column="1" Grid.Row="1">
                                                <Grid.ColumnDefinitions>
                                                    <ColumnDefinition Width="2*"/>
                                                    <ColumnDefinition/>
                                                    <ColumnDefinition/>
                                                </Grid.ColumnDefinitions>
                                                <Path x:Name="path" Visibility="Visible" Stretch="Fill" StrokeThickness="1" StrokeLineJoin="Round" Stroke="#FF000000" Fill="#FFFFFFFF" Data=" M 171.492,7.83671C 193.478,7.83671 212.77,47.3769 223.642,106.839C 242.095,107.511 256.987,154.258 256.987,211.826C 256.987,266.961 243.328,312.17 225.963,316.484C 215.674,383.566 195.142,429.316 171.492,429.316C 144.335,429.316 184.825,347.483 113.143,285.323L 2,285.323L 2,141.33L 114.257,141.33C 177.325,101.495 145.485,7.83671 171.492,7.83671 Z  M 340.181,215.257 Z " Grid.Column="0"/>
                                                <Path x:Name="path1" Visibility="Visible" Stretch="Fill" StrokeThickness="0" StrokeLineJoin="Round" Stroke="#FF000000" Fill="#FFFFFFFF" Data=" M 441.265,210.885C 441.265,130.557 375.401,63.2033 286.734,45.1409L 294.942,2.00004C 415.114,23.697 504.803,108.982 504.803,210.885C 504.803,311.591 417.208,396.067 299.163,418.979L 289.345,376.081C 376.69,357.24 441.265,290.422 441.265,210.885 Z " Grid.Column="2"/>
                                                <Path x:Name="path2" Visibility="Visible" Stretch="Fill" StrokeThickness="0" Stroke="#FF000000" Fill="#FFFFFFFF" Data=" M 340.181,215.257C 340.181,179.811 310.078,149.838 268.689,139.988L 278.911,86.262C 345.758,101.185 395.055,152.793 395.055,214.164C 395.055,274.763 346.991,325.842 281.427,341.485L 269.707,290.278C 310.571,280.183 340.181,250.412 340.181,215.257 Z M 441.265,210.885 Z " Grid.Column="1" StrokeMiterLimit="7" StrokeLineJoin="Round" Margin="0,3,0,5"/>
                                            </Grid>
                                        </Grid>
									    <Viewbox x:Name="viewbox" Opacity="0">
									        <TextBlock Text="X" Foreground="Red"/>
									    </Viewbox>
                                </Grid>
                            </Button>
                        </Viewbox>                    
                        <Viewbox Grid.Column="2" Stretch="Uniform" HorizontalAlignment="Left" Margin="15,4,15,-4">
                            <Button Click="goFullScreen_Clicked"  Width="50" Height="50" IsTabStop="False">
                                <Grid>
                                    <Ellipse Stroke="White" StrokeThickness="3" Fill="#01000001"/>
                                    <Grid>
                                        <Grid.ColumnDefinitions>
                                    	    <ColumnDefinition Width="*"/>
                                    	    <ColumnDefinition Width="4*"/>
                                    	    <ColumnDefinition Width="*"/>
                                        </Grid.ColumnDefinitions>
                                        <Grid.RowDefinitions>
                                    	    <RowDefinition/>
                                    	    <RowDefinition/>
                                    	    <RowDefinition/>
                                        </Grid.RowDefinitions>
                                        <Path Stretch="Fill" StrokeThickness="1" StrokeLineJoin="Round" Stroke="#FF000000" Fill="#FFFFFFFF" Data="F1 M 0,0L 10,0L 10,100L 0,100 Z " Grid.Row="1" Grid.Column="1"/>
                                    </Grid>
                                </Grid>
                            </Button>
                        </Viewbox>                    
                    </Grid>
                <telerik1:RadDockPanel LastChildFill="True" Grid.Row="1" VerticalAlignment="Center">
                    <TextBlock x:Name="curTimeTxt" Text="0:00:00" telerik1:RadDockPanel.Dock="Left" Foreground="White" Margin="2,0,5,0"/>
                    <TextBlock x:Name="totalTimeTxt" Text="0:00:00" telerik1:RadDockPanel.Dock="Right" Foreground="White" Margin="5,0,2,0"/>
                    <Grid VerticalAlignment="Center">
                        <telerik1:RadProgressBar Height="8" Maximum="1" Minimum="0" Style="{StaticResource DownloadProgressBarStyle}" Value="1"/>
                        <telerik1:RadProgressBar x:Name="DownloadProgress" Height="8" Maximum="1" Minimum="0" Style="{StaticResource DownloadProgressBarStyle}" Foreground="LightGray" />
                        <telerik1:RadSlider  IsEnabled="{Binding CanSeek, ElementName=player}" x:Name="slider" ValueChanged="slider_ValueChanged"  Style="{StaticResource TimeSliderStyle}" Cursor="Hand" IsTabStop="False"/>
                    </Grid>                    
           </telerik1:RadDockPanel>
            </Grid>
            </UserControl>
        </Grid>        
        
        <Grid x:Name="failedPanel" HorizontalAlignment="Center" VerticalAlignment="Center" Opacity="0">
            <rad:RadDockPanel LastChildFill="True">
                <Image Width="48" Height="48" Source="../Resources/Error.png" rad:RadDockPanel.Dock="Left"/>
                <TextBlock Text="Не удалось открыть источник мультимедиа" FontWeight="Bold" FontSize="13" Foreground="White" VerticalAlignment="Center"/>
            </rad:RadDockPanel>            
        </Grid>
    	<Grid x:Name="grid3">
    		<Grid.Resources>
    			<ResourceDictionary>
    				<Style TargetType="Button">
    					<Setter Property="Background" Value="Transparent"/>
    					<Setter Property="Margin" Value="0"/>
    					<Setter Property="Template">
    						<Setter.Value>
    							<ControlTemplate TargetType="Button">
    								<ContentPresenter/>
    							</ControlTemplate>
    						</Setter.Value>
    					</Setter>
    				</Style>
    				<Style TargetType="Border">
    					<Setter Property="Background" Value="Transparent"/>
    				</Style>
    			</ResourceDictionary>
    		</Grid.Resources>            
    		<Button x:Name="button2" Click="playPause_Clicked" BorderThickness="0" IsTabStop="False" Cursor="Hand">
    			<Grid Background="Transparent" Width="70" Height="70">
    				<Ellipse Stroke="White" StrokeThickness="3" Fill="#01000001"/>
    				<Grid>
    					<Grid.ColumnDefinitions>
    						<ColumnDefinition/>
    						<ColumnDefinition/>
    						<ColumnDefinition/>
    					</Grid.ColumnDefinitions>
    					<Grid.RowDefinitions>
    						<RowDefinition/>
    						<RowDefinition/>
    						<RowDefinition/>
    					</Grid.RowDefinitions>
    					<Path Grid.Row="1" Grid.Column="1" Stretch="Fill" StrokeThickness="1" StrokeLineJoin="Round" Stroke="#FF000000" Fill="#FFFFFFFF" Data="F1 M 88.0499,58.5L 42.9501,32.4616L 42.9501,84.5384L 88.0499,58.5 Z " Margin="1.5,0,-1.5,0" UseLayoutRounding="False"/>
    				</Grid>
    			</Grid>
    		</Button>            
    	</Grid>
        
        <Grid x:Name="grid" >
            <Popup x:Name="popup" IsOpen="False">
                <Grid Margin="0">                  
                    <Grid x:Name="controlPanelFullScreenPresenter" Margin="0">                       
                    </Grid>
                </Grid>
            </Popup>
        </Grid>
    </Grid>
    
</UserControl>
